# -*- coding: utf-8 -*-
import requests
import json
import urllib2
#detail请求参数
detailjason={
    "request_info": {
        "total_price": "1636",
        "flight": [
            {
                "arr_city": "南京",
                "cabin_code": "G",
                "dep_city": "北京",
                "flight_id": 9472813,
                "adult_num": 1,
                "date": "2014-11-23",
                "child_num": 0
            },
            {
                "arr_city": "北京",
                "cabin_code": "Z",
                "dep_city": "南京",
                "flight_id": 9466012,
                "adult_num": 1,
                "date": "2014-11-21",
                "child_num": 0
            }
        ],
        "uuid": "e4a832d9-786c-4fb1-9faa-6e5919aff08f",
        "is_search": "true",
        "hotel": [
            {
                "checkin_date": "2014-11-21",
                "room_info": [
                    {
                        "room_num": 1,
                        "room_id": "TWN-CN3:DX:RO",
                        "hotel_id": 17952594
                    }
                ],
                "checkout_date": "2014-11-23"
            }
        ],
        "version": 1
    }
}


#往返search价格日历
dp = {"page_info":{"page":1,"page_size":10},
      "sort":[{"key":"default","value":1}],
      "search_info":
          {"flight":[{"adult_num":1,"arr":"上海","child_num":0,"date":"2014-11-20","dep":"北京","filter":{}},
                     {"adult_num":1,"arr":"北京","child_num":0,"date":"2014-11-22","dep":"上海","filter":{}}],
           "hotel":[{"checkin_date":"2014-11-20","checkout_date":"2014-11-22","city":"上海","adult_num":1,"child_num":0,"filter":{"hotel_area":{}}
                    }
           ]
          }
}
#往返机酒list页
listpost={"page_info":
              {"page":1,"page_size":10},
          "sort":[{"key":"default","value":1}],
          "search_info":{"flight":[{"adult_num":1,"arr":"上海","child_num":0,"date":"2014-11-20","dep":"北京","filter":{}},
                                   {"adult_num":1,"arr":"北京","child_num":0,"date":"2014-11-22","dep":"上海","filter":{}}],
                         "hotel":[{"checkin_date":"2014-11-20","checkout_date":"2014-11-22","city":"上海","adult_num":1,"child_num":0,"filter":{"hotel_area":{}
                         }
                                  }
                         ]
          }
}
#往返机酒list页
def wlistpost():
    listurl=json.dumps(listpost)
    listposts=requests.post("http://l-schr3.s.cn6.qunar.com:9999/fp_get_package?version=1",data=listurl)
    print(listposts.text)
wlistpost()
#往返机酒价格日历
def searchget():
    searchurl=json.dumps(dp)
    searchpost=requests.post("http://l-schr3.s.cn6.qunar.com:9999/fp_get_list_date?version=1",data=searchurl)
    print(searchpost.text)
#detail 页
def detailpost():
    httpgodict=json.dumps(detailjason)
    gohttp=requests.post("http://l-schr3.s.cn6.qunar.com:9999/fp_get_detail?version=1",data=httpgodict)
    print(gohttp.text)

